<?php
/**
 * ThinkPHP 3.1.2 
 */
class CloudAction extends AdminbaseAction {

	function _initialize() {
		parent::_initialize();
	}

	function index(){
		echo 1;exit;
		$this->display();
	}

	/**
	 * 设置主页面
	 * @return [type] [description]
	 */
	function setting(){
		$config_file = "data/conf/cloud.php";
		if(file_exists($config_file)){
			$config = include $config_file;
		}else {
			echo 1;
			$config = array();
		}
		// print_r($config);
		$this->assign('config',$config);
		// echo $config['USE_CLOUD'];
		$this->display();
	}

	/**
	 * 选择云存储方式
	 * @return [type] [description]
	 */
	function change(){
		// print_r($_POST);
		$config_file = "data/conf/cloud.php";
		if(file_exists($config_file)){
			$config = include $config_file;
		}else {
			echo 1;
			$config = array();
		}
		$config = array_merge($config,$_POST);

		$data = "<?php return ".var_export($config,true).";?>";
		// echo $data;
		$res = file_put_contents($config_file, $data);

		if($res){
			$this->success('保存成功');
		}else{
			$this->error('失败');
		}
		// print_r($_POST);
		// $this->error();
	}
}